﻿#ifndef UTILS_HPP
#define UTILS_HPP

#ifdef _WIN32
#include <windows.h>
#else // _WIN32
#include <sys/time.h>
#endif // _WIN32

namespace mv {
#ifdef _WIN32
int64_t get_current_time() {
    LARGE_INTEGER freq;
    LARGE_INTEGER pc;
    QueryPerformanceFrequency(&freq);
    QueryPerformanceCounter(&pc);

    return pc.QuadPart * 1000 / freq.QuadPart;
}
#else  // _WIN32
int64_t get_current_time() {
    struct timeval tv;
    gettimeofday(&tv, nullptr);

    return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
#endif // !_WIN32
} // namespace mv

#endif // !UTILS_HPP
